
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Net;

using Swaf;

namespace Swaf.Resource
{
	/// <summary>
	/// Summary description for WebRequestCreator.
	/// </summary>
	public class WebRequestCreator : IWebRequestCreate
	{
		protected string m_requestHandlerClassName;
		public WebRequestCreator(string requestHandlerClassName)
		{
			m_requestHandlerClassName = requestHandlerClassName;
		}
		#region IWebRequestCreate Members

		public WebRequest Create(Uri uri)
		{
			return (WebRequest)Cmn.callCtor(m_requestHandlerClassName,new System.Type[]{uri.GetType()},new object[]{uri});
		}

		private static IClassFactory s_reqHandlrFactory = null;
		public static IClassFactory RequestHandlerFactory
		{
			get
			{
				if(s_reqHandlrFactory == null)
					s_reqHandlrFactory = Application.currentApp.factories["WebRequestHandlers"];
				return s_reqHandlrFactory;
			}
		}

		public static void resetClassFactoryReferences()
		{
			s_reqHandlrFactory = null;
		}

		#endregion
	}
}
